<template>
    <view :style="themeColor">
        <view class="page" >
    <view class="flex benben-position-layout flex flex-wrap align-center realname_flex_0"    :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
            <view   class='flex flex-wrap align-center justify-between flex-sub realname_fd0_0'      >
            <view   class='flex flex-wrap align-center realname_fd0_0_c0'   @tap.stop="handleJumpDiy" data-type="back" data-url="1"   >
        <text class='fu-iconfont2  realname_fd0_0_c0_c0'    >&#xE794;</text>
</view>
    <view   class='flex flex-wrap align-stretch justify-center'      >
        <text class='realname_fd0_0_c1_c0'  >实名认证</text>
</view>
    <view   class='flex flex-wrap align-center justify-end realname_fd0_0_c0'      >
        </view>
</view>

        </view>
<view :style="{height: (88+StatusBarRpx)+'rpx'}"  ></view>
<!---个人信息flex布局开始-->
 <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout realname_flex_1"    >
            <view   class='flex align-center justify-between realname_fd1_0'      >
        <text class='realname_fd1_0_c0'  >姓名</text>
<benben-input class='realname_fd1_0_c1'   type="text" :placeholder="`请输入真实姓名`" confirm-type="done" :maxlength="8" placeholder-style="color:#999;font-size:32rpx"  v-model="datatInfo.name" />
</view>
    <view   class='flex align-center justify-between realname_fd1_1'      >
        <text class='realname_fd1_0_c0'  >手机号</text>
<benben-input class='realname_fd1_1_c1'   type="text" :placeholder="`请输入手机号`" confirm-type="done" :maxlength="11" placeholder-style="color:#999;font-size:32rpx"  v-model="datatInfo.phone" />
</view>
    <view   class='flex align-center justify-between realname_fd1_0'      >
        <text class='realname_fd1_0_c0'  >身份证号</text>
<benben-input class='realname_fd1_1_c1'   type="text" :placeholder="`请输入身份证`" confirm-type="done" :maxlength="18" placeholder-style="color:#999;font-size:32rpx"  v-model="datatInfo.idcard_no" />
</view>
    <view   class='flex flex-direction align-stretch justify-between realname_fd1_3'      >
        <text class='realname_fd1_3_c0'  >上传身份证</text>
    <view   class='flex flex-wrap align-stretch justify-between'      >
            <view   class='flex flex-direction flex-wrap align-center'      >
        <view class="upload position-relative">
    <text v-if="datatInfo.idcard_portrait != ''" @tap="datatInfo.idcard_portrait = ''" class='fu-iconfont2 position-absolute realname_fd1_3_c1_c0_c0_icon'  >&#xE8E7;</text>
     <image class=" realname_fd1_3_c1_c0_c0_image" mode="aspectFit"  @tap="soloChooseImage('portrait_face','idcard_portrait',false,datatInfo)" :src="datatInfo.idcard_portrait ? datatInfo.idcard_portrait : STATIC_URL+'130.png'"></image>
</view>
<text class='realname_fd1_3_c1_c0_c1'  >人像面</text>
</view>
    <view   class='flex flex-direction flex-wrap align-center'      >
        <image class='realname_fd1_3_c1_c1_c0'  mode="aspectFit"  :src='STATIC_URL+"47.png"'></image>
<text class='realname_fd1_3_c1_c0_c1'  >（示例）</text>
</view>
</view>
    <view   class='flex flex-wrap align-stretch justify-between realname_fd1_3_c2'      >
            <view   class='flex flex-direction flex-wrap align-center'      >
        <view class="upload position-relative">
    <text v-if="datatInfo.idcard_emblem != ''" @tap="datatInfo.idcard_emblem = ''" class='fu-iconfont2 position-absolute realname_fd1_3_c1_c0_c0_icon'  >&#xE8E7;</text>
     <image class=" realname_fd1_3_c1_c0_c0_image" mode="aspectFit"  @tap="soloChooseImage('national_face','idcard_emblem',false,datatInfo)" :src="datatInfo.idcard_emblem ? datatInfo.idcard_emblem : STATIC_URL+'130.png'"></image>
</view>
<text class='realname_fd1_3_c1_c0_c1'  >国徽面</text>
</view>
    <view   class='flex flex-direction flex-wrap align-center'      >
        <image class='realname_fd1_3_c1_c1_c0'  mode="aspectFit"  :src='STATIC_URL+"46.png"'></image>
<text class='realname_fd1_3_c1_c0_c1'  >（示例）</text>
</view>
</view>
</view>
</view>
        
<!---个人信息flex布局结束-->
    <view class="flex flex-wrap align-stretch justify-center benben-position-layout flex realname_flex_2"    >
        <button class='realname_fd2_0'  @tap.stop="submitFunc()"  >提交</button>

        </view>
<view :style="{height: '140rpx'}"  ></view>
    
    
        </view>
    </view>
</template>
<script>
    import UploadImage from '@/common/utils/upload-image.js'
import {validate} from '@/common/utils/validate.js'
    
    export default {
        components:{},
        
        
        data(){
			return {"datatInfo":{"aid":"","idcard_no":"","name":"","idcard_emblem":"","idcard_portrait":"","idcard_time":"","reason":"","status":"","phone":""},"national_face":"","portrait_face":""};
		},
		computed:{
            themeColor() {
              return this.$store.getters.themeColor
            },
            
		},
		watch:{},
		onLoad(options){
            
		},
        onUnload() {
                
        },
		onReady(){
            
		},
		onShow(){
            
		},
		onHide(){
            
		},
		onResize(){
            
		},
		onPullDownRefresh(){
            
		},
		onReachBottom(e){
            
		},
		onPageScroll(e){
            
		},
		methods:{
                         //上传单图、多图方法
    soloChooseImage(id, path, obj, obj1, fnName = false) {
      let self = this
      if (!obj) obj = this
      if (!obj1) obj1 = this
      if (self.uploading) {
        return
      }
      // 从相册中选择图片
      uni.chooseImage({
        count: 1, // 默认3
        sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
        success: function (res) {
          self.uploading = true
          // 开始上传
          new UploadImage(res.tempFiles, {
            complete: function (res) {
              self.uploading = false
              if (id) self.$set(obj, id, res[0].id)
              if (path) self.$set(obj1, path, res[0].path)
              if (fnName) self[fnName]()
            },
          })
        },
      })
    },
                //提交
                async submitFunc(){
                                if(!validate(this.datatInfo.name,'require')){
                 this.$message.info('请输入联系人姓名');
                 return false;
            }
            if(!validate(this.datatInfo.phone,'require')){
                 this.$message.info('请输入联系人手机号');
                 return false;
            }
            if(!validate(this.datatInfo.phone,'phone')){
                 this.$message.info('手机号格式不正确');
                 return false;
            }
            if(!validate(this.datatInfo.idcard_no,'require')){
                 this.$message.info('请输入联系人身份证');
                 return false;
            }
            if(!validate(this.datatInfo.idcard_no,'idcard')){
                 this.$message.info('身份证号格式不正确');
                 return false;
            }
            if(!validate(this.datatInfo.idcard_emblem,'require')){
                 this.$message.info('请上传身份证国徽面');
                 return false;
            }
            if(!validate(this.datatInfo.idcard_portrait,'require')){
                 this.$message.info('请上传身份证人像面');
                 return false;
            }
    //请求方法
    //数据验证
    
  let data637c7d436e440 = await this.$api.dbPost(global.apiUrls.post637c7d436e440, {
    phone:this.datatInfo.phone,name:this.datatInfo.name,idcard_no:this.datatInfo.idcard_no,idcard_emblem:this.national_face,idcard_portrait:this.portrait_face,idcard_time:this.datatInfo.idcard_time
  });
  if(!data637c7d436e440) return
  if (data637c7d436e440.data.code != 1) {
    this.$message.info(data637c7d436e440.data.msg);
    return
  } 
  
  
  
    this.$urouter.redirectTo(`/pages/grzx/examine/examine`);
                }
		}
    };
</script> 
<style lang="scss" scoped>
           .page{
            width: 100vw;
            overflow-x: hidden;
            min-height: calc(100vh - var(--window-bottom));
            background:var(--benbenbgColor1);background-size: 100% auto;
        }
    .realname_flex_0{
        background:#fff;width:750rpx;height:88rpx;overflow:hidden;z-index:10;top:0rpx;background-size:100% auto !important;
    }
    .realname_fd0_0_c1_c0{
        font-size:36rpx;font-weight:500;color:#333333;line-height:50rpx;
    }
    .realname_fd0_0_c0_c0{
        font-size:36rpx;color:#333;
    }
    .realname_fd0_0_c0{
        width:120rpx;
    }
    .realname_fd0_0{
        padding:0rpx 32rpx 0rpx 32rpx;
    }
    .realname_flex_1{
        background:#fff;border-radius:16rpx 16rpx 16rpx 16rpx;background-size:100% auto !important;position:relative;margin:32rpx 0rpx 0rpx 0rpx;
    }
    .realname_fd1_3_c2{
        margin:32rpx 0rpx 0rpx 0rpx;
    }
    .realname_fd1_3_c1_c1_c0{
        width:314rpx;height:204rpx;border-radius:0rpx 0rpx 0rpx 0rpx;margin:0rpx 0rpx 24rpx 0rpx;
    }
    .realname_fd1_3_c1_c0_c1{
        color:var(--benbenFontColor0);font-size:28rpx;font-weight:400;
    }
    .realname_fd1_3_c1_c0_c0_image{
        width:314rpx;height:204rpx;margin:0rpx 0rpx 24rpx 0rpx;
    }
    .realname_fd1_3_c1_c0_c0_icon{
        top:0rpx;right:0rpx;z-index:10;color:#ff5536;
    }
    .realname_fd1_3_c0{
        color:var(--benbenFontColor0);font-size:32rpx;font-weight:400;margin:0rpx 0rpx 24rpx 0rpx;
    }
    .realname_fd1_3{
        border-bottom:1px solid rgba(238, 238, 238, 1);padding:32rpx 0rpx 32rpx 0rpx;margin:0rpx 32rpx 0rpx 32rpx;
    }
    .realname_fd1_1_c1{
        text-align:right;margin:0rpx 0rpx 0rpx auto;font-size:32rpx;color:var(--benbenFontColor0);font-weight:400;
    }
    .realname_fd1_1{
        border-bottom:1px solid #eee;background:#fff;padding:30rpx 0rpx 30rpx 0rpx;background-size:100% auto !important;margin:0rpx 32rpx 0rpx 32rpx;
    }
    .realname_fd1_0_c1{
        text-align:right;margin:0rpx 0rpx 0rpx auto;font-size:32rpx;font-weight:400;color:var(--benbenFontColor0);
    }
    .realname_fd1_0_c0{
        color:var(--benbenFontColor0);font-size:32rpx;font-weight:400;line-height:40rpx;
    }
    .realname_fd1_0{
        border-bottom:1px solid #eee;background:#fff;padding:32rpx 0rpx 32rpx 0rpx;background-size:100% auto !important;margin:0rpx 32rpx 0rpx 32rpx;
    }
    .realname_flex_2{
        background:var(--benbenbgColor1);width:750rpx;height:140rpx;overflow:hidden;z-index:10;bottom:calc(0rpx + var(--window-bottom));background-size:100% auto;
    }
    .realname_fd2_0{
        background:var(--benbenbgColor2);border-radius:44rpx 44rpx 44rpx 44rpx;width:686rpx;line-height:88rpx;font-size:32rpx;color:var(--benbenFontColor3);height:88rpx;
    }
</style>